﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace newTurtle8
{
    public partial class OccupationView : UserControl
    {
        CompanyCard cCard;
        SqlCommand selectCmd = SqlManager.SqlCommandFactory(string.Empty);

        public OccupationView(CompanyCard cCard)
        {
            this.cCard = cCard;

            InitializeComponent();
            this.Dock = DockStyle.Fill;

            //setting the usp(User StoredProcedure) for each tabPage.
            tabControl.TabPages.Add(new DataGridTabPage("medic", "usp_displayAllMedic", "חובשים"));
            tabControl.TabPages.Add(new DataGridTabPage("shooter", "usp_displayAllShooters", "קלעים וצלפים"));
            tabControl.TabPages.Add(new DataGridTabPage("machine-gun", "usp_displayAllMachineGunners", "מקלענים"));
            tabControl.TabPages.Add(new DataGridTabPage("m203", "usp_displayAllM203", "מטוליסטים"));
            tabControl.TabPages.Add(new DataGridTabPage("driver", "usp_displayAllDrivers", "נהגים"));
            tabControl.TabPages.Add(new DataGridTabPage("heavy-gun", "usp_displayAllHeavyGunners", "נשק מסייע פלוגתי"));
            tabControl.TabPages.Add(new DataGridTabPage("commander", "usp_displayAllCommanders", "מפקדים"));
        }

        private void tabControl_VisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                DataGridTabPage ptp = (DataGridTabPage)tabControl.TabPages[tabControl.SelectedIndex];
                ptp.refresh();
            }
        }

        private void tabControl_Selecting(object sender, TabControlCancelEventArgs e)
        {
            DataGridTabPage ptp = (DataGridTabPage)tabControl.TabPages[tabControl.SelectedIndex];
            ptp.refresh();
        }
    }
}
    

